package com.example.dao;

import com.example.entity.XueyuanInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;


@Repository
public interface XueyuanInfoDao extends Mapper<XueyuanInfo> {
    @Select("select * from xueyuan_info where name=#{name}")
    XueyuanInfo findByName(String name);

    @Select("select * from xueyuan_info")
    List<XueyuanInfo> selectAllXueyuan();

    @Update("UPDATE xueyuan_info " +
            "SET name = #{name}, decription = #{decription}, score = #{score}" +" "+//这个空格必须加，否则会 报错
            "WHERE id = #{id}")
    void updateById(@Param("id") long id, @Param("name")String name, @Param("decription")String decription,@Param("score") Integer score);

    @Delete("DELETE FROM xueyuan_info WHERE id = #{id}")
    void deleteById(Long id);

    @Select("select * from xueyuan_info")
    List<XueyuanInfo> selectAllTeacher();

    @Select("select * from xueyuan_info where name like concat('%',#{name},'%')")
    List<XueyuanInfo> findByNamePage(String name);

    @Select("select  * from xueyuan_info where id = #{id}")
    XueyuanInfo selectById(Long xueyuanid);
}
